(function(app){
	app.action(['/orderList'], 'order/orderList.html', ['$scope', '$route', '_API', '$location', 	'$timeout', '$rootScope',
		function($scope, $route, _API, $location, $timeout, $rootScope) {
			var myDate = new Date();
			myDate = new Date().getFullYear();
			$scope.date = myDate;
			function reload(){
				_API.ajax('order/orderList',{})
				.success(function(json){
					$scope.data = json.result.datas;
					$scope.PAGE = 1;
				});
			}
			reload();
			
			$scope.remove = function(d) {
				_API.ajax('order/cancleOrder',{"AAZ288":d.AAZ288})
				.success(function(json){
					if(json.result.isPass === true){
						alert(json.result.info);
						reload();
					} else {
						alert(json.result.info);
					}
				});
			}
			
			$scope.pay = function(d) {
				sessionStorage.setItem("AAZ288",d.AAZ288);
				sessionStorage.setItem("BAB502",d.BAB502);
				var shade = document.getElementById('shade'); //支付时页面形成遮罩
				shade.style.display = 'block';
				var orderNumber = d.AAZ288; // 订单号
				var orderAmount = d.AAE022; // 订单金额
				var bankType = d.BAB502; // 银行类别
				window.open($SDC.apiDomain+"/payment?orderNumber="+orderNumber+"&orderAmount="+orderAmount+"&BAB502="+bankType
				+"&payType=1");

			}

			$scope.payOK = function() {
				var shade = document.getElementById('shade'); //支付时页面形成遮罩
				shade.style.display = 'none';
				var AAZ288 = sessionStorage.getItem("AAZ288");
				var BAB502 = sessionStorage.getItem("BAB502");
				
				_API.ajax('order/checkOrder',{"AAZ288":AAZ288,"BAB502":BAB502})
				.success(function(json){
					if(json.isPass === true){
						$location.path("/orderList");
					}
				});
			}
			
			$("#upPage").click(function(){
				var PAGE = document.getElementById("upPage").value;
				if(PAGE == '1'){return;}
				_API.ajax('order/orderList',{"PAGE":parseInt(PAGE)-1})
				.success(function(json){
					$scope.data = json.result.datas;
					$scope.PAGE = parseInt(PAGE)-1;
				});
			});
			
			$("#downPage").click(function(){
				var PAGE = document.getElementById("downPage").value;
				_API.ajax('order/orderList',{"PAGE":parseInt(PAGE)+1})
				.success(function(json){
					if(json.result.datas != null){
						$scope.data = json.result.datas;
						$scope.PAGE = parseInt(PAGE)+1;
					}
				});
			});
		}
	]);
})($SDC.app);